home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / s / insert_texadr.ced < prev    next >
Text File  |  1994-06-06  |  2KB  |  123 lines

  1. /************************************************************************
  2.  *
  3.  * insert_texadr.ced                      by Dirk Federlein
  4.  *
  5.  * Inserts the address of the "person" under the cursor and
  6.  * ends up each line with a "\\" for linebreak.
  7.  * You must have DFA running to use this skript.
  8.  *
  9.  * Lookup part taken from:
  10.  *
  11.  * LookUp.ced                        Copyright (c) 1989, Peter Cherna
  12.  *
  13.  * ARexx program for CygnusEd Professional that looks up the word under
  14.  * the cursor.
  15.  *
  16.  * Version 1.30:  August 20, 1989    Release 1.2:  August 29, 1989
  17.  *
  18.  ************************************************************************/
  19.  
  20. options results
  21.  
  22. address 'rexx_ced'
  23.  
  24. tabchar = '09'X
  25. cr    = '0A'X
  26. /*    Get contents of current line: */
  27. status 55
  28. line = result
  29.  
  30. /*    Get tab size: */
  31. status 8
  32. tabadjust = result - 1
  33.  
  34. /*    Get cursor x position (relative to beginning of line = 1): */
  35. status 46
  36. cur = result + 1
  37.  
  38. i = index(line,tabchar)
  39. DO while i > 0 & i <= cur - tabadjust
  40.     cur = cur - tabadjust
  41.     i = index(line,tabchar,i+1)
  42. END
  43.  
  44. /*    If the current character is non-alphabetic, then start one character
  45.     over to the left.  This allows the cursor to be immediately after
  46.     the key word (say on a space or bracket.) */
  47.  
  48. char = substr(line,cur,1)
  49. if (~(datatype(char,'A') | char = '_') & cur > 1) then
  50.     cur = cur - 1
  51.  
  52. /*    Find leftmost and rightmost alphabetic character adjacent to current: */
  53.  
  54. right = cur - 1
  55. left = cur + 1
  56. char = 'A'
  57. DO while (datatype(char,'A') | char = '_') & (left > 0)
  58.      left = left - 1
  59.     if left > 0 then
  60.         char = substr(line,left,1)
  61. END
  62. char = 'A'
  63. DO while (datatype(char,'A') | (char = '_'))
  64.     right = right + 1
  65.     char = substr(line,right,1)
  66. END
  67.  
  68. if right-left <= 1 then
  69. DO
  70.     getstring
  71.     target = result
  72.     if (target = 'RESULT') then
  73.         exit
  74. END
  75. else
  76. DO
  77.     target = substr(line,left+1,right-left-1)
  78.     newtarget = '#?'target'#?'
  79. END
  80.  
  81. DO
  82.     say 'Searching for address' newtarget '...'
  83.  
  84.     if ~show(ports, DFA) then
  85.     do
  86.         'okay1' 'You should have DFA running, if you' cr 'want to get an address from it!'
  87.         exit 0
  88.     end
  89.  
  90.     address 'DFA' "SEARCH" newtarget "IGNORECASE FIELDS=ALL STEM ADR."
  91.  
  92.     "Prev WORD"
  93.     "Mark BLOCK"
  94.     "NEXT WORD"
  95.     "CUT BLOCK"
  96.  
  97.     if rc=0 then
  98.     do
  99.         text ADR.ADDRESS.0
  100.         text "\\"
  101.         text cr
  102.         text ADR.ADDRESS.2
  103.         text " "
  104.         text ADR.ADDRESS.1
  105.         text "\\"
  106.         text cr
  107.         text ADR.ADDRESS.3
  108.         text "\\"
  109.         text cr
  110.         text ADR.ADDRESS.4
  111.         text " "
  112.         text ADR.ADDRESS.5
  113.         text "\\"
  114.         text cr
  115.         text ADR.ADDRESS.6
  116.         text " "
  117.     end
  118.     else
  119.         'okay1' 'Could not find address of' newtarget '! '
  120.     END
  121.  
  122. exit
  123.